/**
 * 
 */
package easyservice.protocol;

import java.util.Iterator;
import java.util.List;

/**
 * TODO doc
 * 
 * @author Rodrigo Barbosa Lira
 * 
 */
public class RequestCommand extends SyncCommand {
	
	private String method;
	private List<String> params;

	/**
	 * @param method
	 * @param params
	 */
	public RequestCommand(String method, List<String> params) {
		this.method = method;
		this.params = params;
	}


	/**
	 * @return the method
	 */
	public String getMethod() {
		return method;
	}


	/**
	 * @param method the method to set
	 */
	public void setMethod(String method) {
		this.method = method;
	}


	/**
	 * @return the params
	 */
	public List<String> getParams() {
		return params;
	}


	/**
	 * @param params the params to set
	 */
	public void setParams(List<String> params) {
		this.params = params;
	}
	
	/* (non-Javadoc)
	 * @see easyservice.protocol.AbstractCommand#generatedString()
	 */
	@Override
	public String generatedString() {
		StringBuffer generatedString = new StringBuffer("# " + CommandEnum.REQUEST + " ");
		generatedString.append(this.getMethod() + " ");
		for (Iterator<String> iterator = this.getParams().iterator(); iterator.hasNext();) {
			String param = (String) iterator.next();
			generatedString.append(param);
			if (iterator.hasNext())
				generatedString.append(" ");
		}		
		return generatedString.toString();
	}

}
